import 'package:flutter/material.dart';

class PageViewFullPage extends StatefulWidget {
  const PageViewFullPage({super.key});

  @override
  State<PageViewFullPage> createState() => _PageViewFullPageState();
}

class _PageViewFullPageState extends State<PageViewFullPage> {
  List<Widget> list = [];

  @override
  void initState() {
    super.initState();
    for (int i = 0; i < 8; i++) {
      list.add(
        Center(
          child: Text("Day${i + 1}"),
        ),
      );
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("PageViewFull"),
      ),
      body: PageView(
        scrollDirection: Axis.vertical,
        // 无限加载
        onPageChanged: (index) {
          if (index == list.length - 1) {
            list.add(
              Center(
                child: Text("Day${list.length + 1}"),
              ),
            );
            setState(() {});
          }
        },
        children: list,
      ),
    );
  }
}
